import Vue from "vue";
import VueRouter from "vue-router";
import login from "../views/Login.vue";
import HappyHome from "../views/HappyHome.vue";
// import user from "../views/HappyHomeUser.vue";
// import home from "../views/HappyHomehome.vue";
// import Live from "../views/HappyHomeLive.vue";
// import Work from "../views/HappyHomeWork.vue";
// import Leisure from "../views/HappyHomeLeisure.vue";
// import LiveCookbook from "../views/LiveCookbook.vue";
// import LiveNutritiousfood from "../views/LiveNutritiousfood.vue";
// import LiveGetleandiet from "../views/LiveGetleandiet.vue";
// import LiveWeeklymenu from "../views/LiveWeeklymenu.vue";
// import LwyAccountBook from "../views/LwyAccountBook.vue";
// import LwyFamilyAccount from "../views/LwyFamilyAccount.vue";
// import LwyIoperate from "@/views/LwyIoperate.vue";
// import LwyDetails from "../views/LwyDetails.vue";
// import LwyThatPersonAccount from "../views/LwyThatPersonAccount.vue";
// // import LwyDeposit from "../views/LwyDeposit.vue";
// import KeeShi from "../views/KeeShi.vue";
// import KeePingLive from "../views/KeePingLive.vue";
// import KeeDaKa from "../views/KeeDaKa";
// import YuJia from "../views/KeeShi/YuJia.vue";
// import Pugo from "../views/KeeShi/Pugo.vue";
// import DiTu from "../views/KeeShi/DiTu.vue"
// import WoMan from "../views/KeeShi/WoMan.vue"
// import KeeWeight from "../views/KeeWeight";
//import FriendChata from "../views/FriendChata.vue";
// import Notepad from "../views/Notepad.vue";
// import Navigation from "../views/navigator.vue";
// import Clocks from "../views/Clocks.vue";
// import FavrioteLive from '../views/FavrioteLive.vue'
// import FatdetailsLive from '../views/FatdetailsLive.vue'
// import Revenueinfo from "../views/Revenueinfo.vue";
// import LiveDayrecommend from '../views/LiveDayrecommend.vue'
// import FatdetailsLive from '../views/FatdetailsLive.vue'
// // import Revenueinfo from "../views/Revenueinfo.vue";
// import LiveDayrecommend from '../views/LiveDayrecommend.vue'
//import PersonSet from '../views/PersonSet.vue'
import editUser from '../views/editUser.vue'
Vue.use(VueRouter);
const routes = [
  {
    path: "/",
    name: "login",
    component: login,
  },
  {
    path: "/editUser",
    name: "editUser",
    component: editUser,
  },
  {
    path: "/HappyHome",
    name: "HappyHome",
    component: HappyHome,
    children: [
      {
        path: "/HappyHome/user",
        component: () => import("../views/HappyHomeUser.vue"),
      },
      {
        path: "/HappyHome/home",
        component: () => import("../views/HappyHomehome.vue"),
      },
      {
        path: "/HappyHome/home/FriendChata",
        component: () => import("../views/FriendChata.vue"),
      },
      {
        path: "/HappyHome/home/PersonSet",
        component: () => import("../views/PersonSet.vue"),
      },
      {
        path: "/HappyHome/home/Favriote",
        component: () => import("../views/FavrioteLive.vue"),
      },
      {
        path: "/HappyHome/live",
        // component: Live,
        component: () => import("../views/HappyHomeLive.vue"),
        children: [
          {
            path: "/HappyHome/live/cook",
            // component: LiveCookbook,
            component: () => import("../views/LiveCookbook.vue"),
          },
          {
            path: "/HappyHome/live/nutritious",
            // component: LiveNutritiousfood,
            component: () => import("../views/LiveNutritiousfood.vue"),
          },
          {
            path: "/HappyHome/live/getleandiet",
            // component: LiveGetleandiet,
            component: () => import("../views/LiveGetleandiet.vue"),
          },
          {
            path: "/HappyHome/live/weekly",
            // component: LiveWeeklymenu,
            component: () => import("../views/LiveWeeklymenu.vue"),
          },

          {
            path: "/HappyHome/live/account",
            // component: LwyAccountBook,
            component: () => import("../views/LwyAccountBook.vue"),
          },
          {
            path: "/HappyHome/live/family",
            // component: LwyFamilyAccount,
            component: () => import("../views/LwyFamilyAccount.vue"),
          },
          {
            path: "/HappyHome/live/ioperate",
            // component: LwyIoperate,
            component: () => import("@/views/LwyIoperate.vue"),
          },
          {
            path: "/HappyHome/live/details",
            // component: LwyDetails,
            component: () => import("../views/LwyDetails.vue"),
          },
          {
            path: "/HappyHome/live/person",
            // component: LwyThatPersonAccount,
            component: () => import("../views/LwyThatPersonAccount.vue"),
          },
          // {
          //   path: "/HappyHome/live/person",
          //   component: LwyThatPersonAccount,
          // },
          {
            path: "/HappyHome/live/deposit",
            component: () => import("../views/LwyDeposit.vue"),
          },
          {
            path: "/HappyHome/live/Fatdetails",
            // component: FatdetailsLive,
            component: () => import("../views/FatdetailsLive.vue"),
          },
          {
            path: "/HappyHome/live/Dayrecommend",
            // component: LiveDayrecommend,
            component: () => import("../views/LiveDayrecommend.vue"),
          },
        ],
      },
      {
        path: "/HappyHome/work",
        name: "work",
        component: () => import("../views/HappyHomeWork.vue"),
        children: [
          {
            path: "/HappyHome/work/notepad",
            name: "notepad",
            component: () => import("../views/Notepad.vue"),
          },
          {
            path: "/HappyHome/work/Navigation",
            name: "navigation",
            component: () => import("../views/navigator.vue"),
          },
          {
            path: "/HappyHome/work/clocks",
            name: "clocks",
            component: () => import("../views/Clocks.vue"),
          },
          {
            path: "/HappyHome/work/revenueinfo",
            name: "revenueinfo",
            component: () => import("../views/Revenueinfo.vue"),
          },
        ],
      },
      {
        path: "/HappyHome/leisure",
        // component: Leisure,
        component: () => import("../views/HappyHomeLeisure.vue"),
        children: [
          {
            path: "/",
            name: "keepinglive",
            // component: KeePingLive,
            component: () => import("../views/KeePingLive.vue"),
          },
          {
            path: "/HappyHome/leisure/keepinglive",
            name: "keepinglive",
            component: () => import("../views/KeePingLive.vue"),
          },
          {
            path: "/happyhome/leisure/yujia",
            name: "yujia",
            component: () => import("../views/KeeShi/YuJia.vue"),
          },
          {
            path: "/happyhome/leisure/pugo",
            name: "pugo",
            component: () => import("../views/KeeShi/Pugo.vue"),
          },
          {
            path: "/happyhome/leisure/ditu",
            name: "ditu",
            component: () => import("../views/KeeShi/DiTu.vue"),
          },
          {
            path: "/happyhome/leisure/keeshi",
            // component: KeeShi,
            component: () => import("../views/KeeShi.vue"),
          },
          {
            path: "/HappyHome/leisure/keedaka",
            // component: KeeDaKa,
            component: () => import("../views/KeeDaKa"),
          },
          {
            path: "/HappyHome/leisure/woman",
            // component: WoMan,
            component: () => import("../views/KeeShi/WoMan.vue"),
          },
          {
            path: "/HappyHome/leisure/keeweight",

            component: () => import("../views/KeeWeight"),
          },
        ],
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

// router.beforeEach((to, from, next) => {
//   //如果去登录页
//   if (to.path == '/') {
//     next()
//   } else {
//     //进非登录页面
//     //判断是否登录过
//     let power = JSON.parse(sessionStorage.getItem('power'));
//     if (power) {
//       //登陆过
//       console.log(2, '登录过', router.getRoutes());
//       let arr = router.getRoutes()
//       if (arr.length >=3) {
//         console.log(3, '已经添加过路由了')
//         next();
//       } else {
//         console.log(4, '登录，但是刷新了')
//         power.forEach((v) => {
//           console.log(444,v.path);
//           router.addRoute('HappyHome', { path: v.path, component:v.component})
//         })
//         //加载好了重新近一次
//         next()
//       }
//     } else {
//       //没登陆过
//       console.log(2, '没登录')
//       next({ path: '/', replace: true })
//     }
//   }
// })

export default router;
